//
//  CommonTableViewCell.m
//  BGM
//
//  Created by liuqin on 2018/12/7.
//  Copyright © 2018 com.alirtc.demo. All rights reserved.
//

#import "CommonTableViewCell.h"
#import "Common.h"

@interface CommonTableViewCell()

@property (nonatomic, strong)UILabel *headLabel;
@property (nonatomic, strong)UILabel *commonLabel;
@property (nonatomic, strong)UILabel *timeLabel;

@end



@implementation CommonTableViewCell


-(instancetype)initWithStyle:(UITableViewCellStyle)style reuseIdentifier:(NSString *)reuseIdentifier{
    self = [super initWithStyle:style reuseIdentifier:reuseIdentifier];
    if (self !=nil) {
        
        self.headLabel = [[UILabel alloc]initWithFrame:CGRectMake(10, 15, 40, 40)];
        self.headLabel.textColor = bgmgrayColor;
        self.headLabel.textAlignment = NSTextAlignmentCenter;
        self.headLabel.font = [UIFont systemFontOfSize:14];
         self.headLabel.layer.cornerRadius = 20;
        self.headLabel.layer.masksToBounds = YES;
        self.headLabel.backgroundColor = bgmColor(224, 224, 224);
        [self addSubview:self.headLabel];
        
        
        self.commonLabel = [[UILabel alloc]initWithFrame:CGRectMake(55, 15, SCREENW-65, 40)];
        self.commonLabel.textColor = bgmgrayColor;
        self.commonLabel.numberOfLines = 0;
        [self.commonLabel sizeToFit];
        self.commonLabel.font = [UIFont systemFontOfSize:14];
       
        [self addSubview:self.commonLabel];
        
        
        self.timeLabel = [[UILabel alloc]initWithFrame:CGRectMake(SCREENW-100, 0, 90, 15)];
        self.timeLabel.textColor = bgmsmallColor;
        self.timeLabel.textAlignment = NSTextAlignmentRight;
        self.timeLabel.font = [UIFont systemFontOfSize:11];
         [self addSubview:self.timeLabel];

    }
    return self;
}
-(void)setUserCommonText:(NSDictionary *)dic row:(int)row{

    self.headLabel.text = [NSString stringWithFormat:@"#%d",row];
    self.commonLabel.text = [NSString stringWithFormat:@"%@",[dic objectForKey:@"content"]];
    self.timeLabel.text = [NSString stringWithFormat:@"%@",[dic objectForKey:@"times"]];
    UIFont * tfont = [UIFont systemFontOfSize:14];
    NSDictionary * tdic = [NSDictionary dictionaryWithObjectsAndKeys:tfont,NSFontAttributeName,nil];
    CGSize  actualsize =[self.commonLabel.text boundingRectWithSize:CGSizeMake(SCREENW-65, MAXFLOAT) options:NSStringDrawingUsesLineFragmentOrigin  attributes:tdic context:nil].size;
    
    self.commonLabel.frame = CGRectMake(55, 15, SCREENW-65,  actualsize.height>40?actualsize.height:40);

    
}


- (void)awakeFromNib {
    [super awakeFromNib];
    // Initialization code
}

- (void)setSelected:(BOOL)selected animated:(BOOL)animated {
    [super setSelected:selected animated:animated];

    // Configure the view for the selected state
}

@end
